package cn.ewan.cloud.tenant.data.router.mq;

import cn.ewan.cloud.common.support.Log;
import cn.ewan.cloud.common.web.support.rocketmq.config.RocketMqAutoConfiguration;
import cn.ewan.cloud.tenant.data.router.mq.core.TenantRocketMQProducer;
import cn.ewan.cloud.tenant.data.router.spring.build.BuildUtil;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;

/**
 * @author lgh
 * @date 2023/3/2 16:19
 */
@AutoConfigureBefore({RocketMqAutoConfiguration.class})
public class TenantMqAutoConfiguration implements InitializingBean {

    public TenantMqAutoConfiguration() {
    }


    @ConditionalOnProperty({"rocketmq.producer.group"})
    @Bean
    public TenantRocketMQProducer tenantRocketMQProducer() {
        return new TenantRocketMQProducer();
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        String buildTime = new BuildUtil().logBuildTime();
        Log.NORMAL.info("===========tenant-mq init finish=======, buildTime={}", buildTime);
    }
}
